<?php
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
$selectProM = mysql_query("SELECT e.FullName,pr.NameProject,pr.IDProject,pr.`Status`,DATE_FORMAT(pr.DateStart,'%Y-%m-%d') as DateStart
						 FROM employee e,pr_project pr
 						WHERE e.IDManager = pr.IDManager AND e.IDEmployee = '$id_employee'");

//$selectpro = mysql_query("SELECT p.IDProject, p.NameProject, e.FullName, DATE_FORMAT(p.DateStart,'%Y-%m-%d') as DateStart, p.`Status`
  //       FROM pr_project p,pr_composition c, employee e 
   //      WHERE c.IDEmployee = '$id_employee' AND p.IDProject = c.IDProject AND e.IDEmployee = c.IDEmployee AND (e.IDManager != p.IDManager) 
   //      GROUP BY p.IDProject ORDER BY p.NameProject ASC");
   $selectpro = mysql_query("SELECT p.IDProject, p.NameProject, e.FullName, DATE_FORMAT(p.DateStart,'%Y-%m-%d') as DateStart, p.`Status`
         FROM pr_project p,pr_composition c, employee e 
         WHERE c.IDEmployee = '$id_employee' AND p.IDProject = c.IDProject AND e.IDManager = p.IDManager  
         GROUP BY p.IDProject ORDER BY p.NameProject ASC");
?>
<link
	href="css/style.css" rel="stylesheet" type="text/css" />
<div id="contains" style="background-color: #edf4f7;">

	<div class="title"></div>
	<div class="body" id="contentLstPro">
		<div id="listProjectM" style="margin-left: 10px;">
			<span class="caption"><?php echo $l_projectlist." - ".$l_manager?></span>
			<table id="listProM" width="100%" class="cssTable">
				<thead>
					<tr style="background-color: #216ca3;">
						<th scope="col"><?php echo $l_code?></th>
						<th scope="col"><?php echo $l_project_name?></th>
						<th scope="col"><?php echo $l_manager?></th>
						<th scope="col"><?php echo $l_status?></th>
						<th scope="col"><?php echo $l_start_date?></th>
					</tr>
					<?php
					while ($rowM = mysql_fetch_array($selectProM)){
						?>
					<tr style="background-color: #edf4f7;">
						<td style="vertical-align: middle;"><a href="project.php?projectDetail=project-detail&id=<?=$rowM[IDProject]?>"><?php echo $rowM[IDProject]?></a></td>
						<td style="vertical-align: middle;"><a href="project.php?projectDetail=project-detail&id=<?=$rowM[IDProject]?>"><?php echo $rowM[NameProject]?></a></td>
						<td style="vertical-align: middle;"><?php echo $rowM[FullName]?></td>
						<td style="vertical-align: middle;"><?php if($rowM[`Status`]==0){echo $l_status_project_no;}else if($rowM[`Status`]==1){echo $l_status_project_done;}?>
						</td>
						<td style="vertical-align: middle;"><?php echo $rowM[DateStart]?></td>
					</tr>
					<?php
					}
					?>
				</thead>
			</table>
		</div>

		<div id="listProject" style="margin-left: 10px;">
			<span class="caption"><?php echo $l_projectlist." - ".$l_memb?></span>
			<table id="listPro" width="100%" class="cssTable"
				style="background: #216ca3;">
				<thead>
					<tr>
						<th scope="col"><?php echo $l_code?></th>
						<th scope="col"><?php echo $l_project_name?></th>
						<th scope="col"><?php echo $l_manager?></th>
						<th scope="col"><?php echo $l_status?></th>
						<th scope="col"><?php echo $l_start_date?></th>
					</tr>
					<?php 
						while ($row = mysql_fetch_array($selectpro)){
							?>
							<tr style="background-color: #edf4f7;">
						<td style="vertical-align: middle;">
						<a href="project.php?projectDetail=project-detail&id=<?=$row[IDProject]?>"><?php echo $row[IDProject]?></a></td>
						<td style="vertical-align: middle;"><a href="project.php?projectDetail=project-detail&id=<?=$row[IDProject]?>"><?php echo $row[NameProject]?></a></td>
						<td style="vertical-align: middle;"><?php echo $row[FullName]?></td>
						<td style="vertical-align: middle;"><?php if($row[`Status`]==0){echo "Uncompleted";}else if($row[`Status`]==1){echo "Completed";}?>
						</td>
						<td style="vertical-align: middle;"><?php echo $row[DateStart]?></td>
					</tr>
							<?php 
						}
					?>
				</thead>
			</table>
		</div>
	</div>
</div>
